package com.ywk.rabbitmqProd.business.controller;

import com.ywk.rabbitmqProd.base.sender.MQSender;
import com.ywk.rabbitmqProd.business.message.BusinessMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zbh
 * @Date 2023/5/18
 */
@RestController
@RequestMapping("/sender")
public class SenderController {

    @Autowired
    MQSender sender;

    @RequestMapping("/send")
    public String send(String message) {
        sender.send(message);
        return "rabbitmq send message，success";
    }

    @RequestMapping("/sendDirect")
    public String sendDirect() {
        sender.sendDirect("hello,rabbitmq sendDirect");
        return "rabbitmq sendDirect message，success";
    }

    @RequestMapping("/sendFanout")
    public String sendFanout() {
        sender.sendFanout("hello,rabbitmq sendFanout");
        return "rabbitmq sendFanout message，success";
    }

    @RequestMapping("/sendTopic")
    public String sendTopic() {
        sender.sendTopic("hello,rabbitmq sendTopic");
        return "rabbitmq sendTopic message，success";
    }

    @RequestMapping("/sendHeader")
    public String sendHeader() {
        sender.sendHeader("hello,rabbitmq sendHeader");
        return "rabbitmq sendHeader message，success";
    }

    @RequestMapping("/sendBusiness")
    public void sendBusiness() {
        BusinessMessage businessMessage = new BusinessMessage(1,"hello rabbitMQ");
        sender.sendBusinessMessage(businessMessage);
    }
}
